// ==================================================================================
// Shared Genomics Project MPI Codebase
// Version 1.0 30/04/2010
//
// (c) 2010 University of Manchester all rights reserved
//
// This file is distributed under the GNU General Public License, Version 2.  
// Please see the file COPYING.txt for more details
// ==================================================================================

#ifndef _FOUNDERSFILE_H_
#define _FOUNDERSFILE_H_

#include "pedfile.h"
#include "options.h"

#ifdef __cplusplus
extern "C" {
#endif

/*!
\file
\ingroup	gio
\brief		Gender and Founder Data
\details	
	This header encodes gender and founder data passed to the cores of the NIBHI cluster.<br>
	Gender encoding rules are TRUE = male, FALSE = female.<br>
	A 'founder' file contains 2 blocks of BOOL data of the same size.<br>
	The first block is gender information and the second block is the 'founders' data.<br>
	If a person is not flagged as a founder, they are ignored by some analysis algorithms.<br>
	By default all people in a data-set are flagged as a founder.<br>
	A founder is a PLINK concept denoting that for certain algorithms people in a data-set may be ignored
	if they have a familial relationship with other individuals within that data-set.<br>
	A founder files uses the file suffix \ref SUFFIX_FOUNDERS_FILE.
*/

/*!
\brief Create a founders file.
\details
	The output file name is a concatonation of \ref selected_options::ldir, 
	\ref selected_options::szRunId and \ref SUFFIX_FOUNDERS_FILE.
\param [in] p Source of the founders data
\param [in] ops Output file location
\returns 1 on success, 0 on failure
*/
int foundersfile_create(struct pedfile *p, struct selected_options *ops);

/*!
\brief Load a founders file.
\details
	The input file name is a bound to the variable \ref selected_options::szFoundersFileName
	and typically has a file suffix of \ref SUFFIX_FOUNDERS_FILE.
\param [in] ops Input file location
\param [in,out] nSamples Pointer to No. samples/people in the founder files
\returns BOOL array or NULL on failure
*/
BOOL* foundersfile_load(struct selected_options *ops, int *nSamples);

/*!
\brief Create a founders file and copy to a remote working directory.
\details
	The output filename is a concatonation of selected_options::rdir, 
	\ref selected_options::szRunId and \ref SUFFIX_FOUNDERS_FILE.
\param [in] p Genomic data-set containing founders data
\param [in] ops Output file location
\param [in] rank Local processor rank
\returns 1 on success, 0 on failure
*/
int foundersfile_create_and_copy(struct pedfile *p, struct selected_options *ops, int rank);

#ifdef __cplusplus
}
#endif

#endif // _FOUNDERSFILE_H_
